import React, { Component } from "react";

class App extends Component {
  constructor() {
    super();
    this.state = {
      url: "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png",
      show: true,
      list: ["zhangsan", "lisi"],
      content: "<h1>标题</h1>",
    };
  }
  render() {
    return (
      <>
        <h2>state练习</h2>
        <img src={this.state.url} alt="" />
        {this.state.show ? <p>hello</p> : null}
        {this.state.show && <p>hello</p>}
        <ul>
          {this.state.list.map((item) => (
            <li key={item}>{item}</li>
          ))}
        </ul>
        <div>{this.state.content}</div>
        {/* 相当于vue的v-html */}
        <div dangerouslySetInnerHTML={{ __html: this.state.content }}></div>
      </>
    );
  }
}

export default App;
